
package x.java.tea;

import java.io.IOException;

/**
 * @author qiangli
 *
 */
public interface Injector {
	
	/**
	 * This method is called once before any injection takes place, giving the
	 * implementing class an opportunity to set up any resources that are
	 * required during injection.
	 * 
	 * @param id
	 *            the marker in the template
	 */
	public void init(String id);

	/**
	 * Inject some number of bytes into the buffer array b. The actual number of
	 * bytes read is returned as an integer. This method blocks until input data is
	 * available, end of data is detected, or an exception is thrown.
	 * 
	 * If no byte is available, the value -1 is returned; otherwise, at least
	 * one byte is read and stored into b.
	 * 
	 * @param b the buffer into which the data is read. or -1 if there is no more data to be read
	 * @return  the total number of bytes read into the buffer.
	 * @throws  IOException
	 */
	public int inject(byte[] b) throws IOException;
}
